package com.wc.alorithm_luogu.P1164;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.util.Arrays;

/**
 * P1164 小A点菜
 * https://www.luogu.com.cn/problem/P1164
 */
public class Main {
    public static void main(String[] args) {
        Input sc = new Input();

        int N = sc.nextInt();
        int M = sc.nextInt();

        int[] array = new int[N];
        for (int i = 0; i < N; i++) {
            array[i] = sc.nextInt();
        }

        Arrays.sort(array);
        Main main = new Main();
        System.out.println(main.sumNum2(array,M));
    }

    public int sumNum(int[] array, int index, int sum) {
        if (sum == 0) {
            return 1;
        } else if (sum < 0 || index == array.length) {
            return 0;
        }
        int ans = 0;
        ans += sumNum(array, index + 1, sum - array[index]);
        ans += sumNum(array, index + 1, sum);

        return ans;
    }

    public int sumNum2(int[] array, int sum) {
        int[][] dp = new int[array.length + 1][sum+1];

        for (int i = 0; i < array.length; i++) {
            for (int j = 1; j <= sum; j++) {
                if (array[i] > j) {
                    dp[i + 1][j] = dp[i][j];
                } else if (array[i] == j) {
                    dp[i + 1][j] = dp[i][j] + 1;
                } else {
                    dp[i + 1][j] = dp[i][j] + dp[i][j - array[i]];
                }
            }
        }
        return dp[array.length][sum];
    }

    static class Input {
        StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));

        public int nextInt() {
            try {
                in.nextToken();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return (int) in.nval;
        }
    }
}
